package com.ziyun.erp.web.modules.order.controller;

import com.ziyun.erp.modules.order.entity.DesignInfoEntity;
import com.ziyun.erp.modules.order.service.DesignInfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 订单设计表
 *
 * @author gaosheng
 * @email 
 * @date 2018-08-09 15:55:54
 */
@RestController
@RequestMapping("order/designinfo")
public class DesignInfoController {
    @Autowired
    private DesignInfoService designInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("order:designinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = designInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{designInfoId}")
    @RequiresPermissions("order:designinfo:info")
    public R info(@PathVariable("designInfoId") Integer designInfoId){
        DesignInfoEntity designInfo = designInfoService.selectById(designInfoId);

        return R.ok().put("designInfo", designInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("order:designinfo:save")
    public R save(@RequestBody DesignInfoEntity designInfo){
        designInfoService.insert(designInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("order:designinfo:update")
    public R update(@RequestBody DesignInfoEntity designInfo){
        ValidatorUtils.validateEntity(designInfo);
        designInfoService.updateAllColumnById(designInfo);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("order:designinfo:delete")
    public R delete(@RequestBody Integer[] designInfoIds){
        designInfoService.deleteBatchIds(Arrays.asList(designInfoIds));

        return R.ok();
    }

}
